package simportal.persistent;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.cfuture08.eweb4j.orm.config.annotation.Column;
import com.cfuture08.eweb4j.orm.config.annotation.Id;
import com.cfuture08.eweb4j.orm.config.annotation.ManyMany;
import com.cfuture08.eweb4j.orm.config.annotation.Table;
import com.cfuture08.util.JsonConverter;

/**
 * 用户-持久化对象
 * 
 * @author weiwei[l.weiwei@163.com]
 * 
 */
@Table("t_User")
public class User implements Serializable{
	/**
	 * 用于分布式服务器
	 */
	private static final long serialVersionUID = -3248564641931360005L;
	@Id
	@Column("")
	private Integer id;// 自增长id
	@Column("")
	private String trueName;// 真实姓名，2-3位，中文
	@Column("")
	private String account;// 账号,4-16
	@Column("")
	private String password;// 密码，4-32,MD5加密
	@Column("")
	private String status;// 用户状态：'在线'、'下线'、'锁定'
	@Column("")
	private String lastLoginTime;// 上一次登陆时间
	@Column("")
	private String lastLoginIp;// 上一次登陆IP
	// 用户与角色时多对多关系
	@ManyMany(target = Role.class, relTable = "t_User_Role", from = "userId", to = "roleId")
	private List<Role> roles = new ArrayList<Role>();// 角色

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTrueName() {
		return trueName;
	}

	public void setTrueName(String trueName) {
		this.trueName = trueName;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(String lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public String getLastLoginIp() {
		return lastLoginIp;
	}

	public void setLastLoginIp(String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public String toString() {
		return JsonConverter.convert(this);
	}
}
